import fileinput

from selenium import webdriver
import time

from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys

driver=webdriver.Chrome()
# driver.get("https://www.baidu.com/")
# driver.get('http://www.baidu.com')
# driver.find_element_by_id("kw").send_keys("申子怡")
# driver.find_element_by_id("su").click()
# driver.find_element_by_name("wd").send_keys("li")
# driver.find_element_by_id("su").click()
# driver.find_element_by_link_text("hao123").click()
# driver.find_element_by_xpath("//*[@id='kw']").send_keys("szy")
# driver.find_element_by_xpath("//*[@id='su']").click()
# driver.find_element_by_xpath("//*[@id='su']").submit()
# time.sleep(1)
# driver.find_element_by_xpath("//*[@id='kw']").clear()
# driver.find_element_by_xpath("//*[@id='kw']").send_keys("申子怡")
# driver.find_element_by_xpath("//*[@id='su']").click()
# tx=driver.find_element_by_xpath("//*[@id='5']/div/div[1]/h3/a").text
# driver.implicitly_wait
# driver.find_element_by_link_text("hao123").click()
# data=driver.find_element_by_xpath("//*[@id='s-top-left']/a[2]").text
# data1=driver.find_element_by_xpath("//*[@id='hotsearch-content-wrapper']/li[3]/a/span[2]").text
# driver.find_element_by_xpath("//*[@id='hotsearch-refresh-btn']/span").click()
# data2=driver.find_element_by_xpath("//*[@id='hotsearch-content-wrapper']/li[3]/a/span[2]").text
# driver.find_element_by_xpath("//*[@id='hotsearch-content-wrapper']/li[3]/a/span[2]").click()

#设置浏览器宽高
# driver.set_window_size(200,400)

# #浏览器滚动条控制
# js = "var q=document.documentElement.scrollTop=10000"
# driver.execute_script(js)
#
# js1 = "var q=document.documentElement.scrollTop=0"
# driver.execute_script(js1)
#
# time.sleep(1)
# 窗口最大化
# driver.maximize_window()
# time.sleep(1)
# driver.back()
# time.sleep(3)
# t=driver.title
# print(t)
# print(driver.current_url)
#
# # print(tx)
# print(data)
# print(data1)
# print(data2)
# driver.get("http://114.115.248.185:8080/imageSys")
# driver.find_element_by_id("username").send_keys("abc")
# driver.find_element_by_id("username").send_keys(Keys.TAB)
# driver.find_element_by_id("password").send_keys("123")
# time.sleep(1)
# driver.find_element_by_id("password").send_keys(Keys.TAB)
# driver.find_element_by_id("submit").send_keys(Keys.ENTER)
# time.sleep(10)


# 键盘控制
# driver.find_element_by_name("wd").send_keys("元旦快乐")
# time.sleep(2)
# driver.find_element_by_name("wd").send_keys(Keys.CONTROL,'a')
# time.sleep(2)
# driver.find_element_by_name("wd").send_keys(Keys.CONTROL,'x')
# driver.find_element_by_name("wd").send_keys("2023")

# # 右击
# qqq = driver.find_element_by_xpath("//*[@id='su']")
# ActionChains(driver).context_click(qqq).perform()
# 拖动
# 拖动 = driver.find_element_by_xpath("//*[@id='hotsearch-content-wrapper']/li[1]/a/span[2]")
# 目的地=driver.find_element_by_xpath("//*[@id='kw']")
# ActionChains(driver).move_to_element(kw).perform().submit()


# 定位一组tag name 都为input的元素
# driver.get("http://localhost:8080/seleniumhtml/checkbox.html")
# buttons = driver.find_elements_by_tag_name("input")
# for button in buttons:
#     # if button.get_attribute('type') == 'checkbox':
#         button.click()

# # 从默认页面到 f1 框架页面
# driver.get("http://localhost:8080/seleniumhtml/frame.html")
# driver.switch_to.frame("f1")
# driver.find_element_by_link_text("click").click()
# # 回到默认页面
# driver.switch_to.default_content()


time.sleep(2)
driver.quit()